package org.example.observer;

import java.util.Date;

public class EnvironmentData {
    private Date timestamp;
    private double soilMoisture;
    private double soilPH;
    private double temperature;
    private double humidity;
    private double windSpeed;
    private String cropStatus;
    private boolean hasObstacle;
    private double obstacleDistance;

    public EnvironmentData() {
        this.timestamp = new Date();
    }

    public Date getTimestamp() { return timestamp; }
    public void setTimestamp(Date timestamp) { this.timestamp = timestamp; }
    public double getSoilMoisture() { return soilMoisture; }
    public void setSoilMoisture(double soilMoisture) { this.soilMoisture = soilMoisture; }
    public double getSoilPH() { return soilPH; }
    public void setSoilPH(double soilPH) { this.soilPH = soilPH; }
    public double getTemperature() { return temperature; }
    public void setTemperature(double temperature) { this.temperature = temperature; }
    public double getHumidity() { return humidity; }
    public void setHumidity(double humidity) { this.humidity = humidity; }
    public double getWindSpeed() { return windSpeed; }
    public void setWindSpeed(double windSpeed) { this.windSpeed = windSpeed; }
    public String getCropStatus() { return cropStatus; }
    public void setCropStatus(String cropStatus) { this.cropStatus = cropStatus; }
    public boolean isHasObstacle() { return hasObstacle; }
    public void setHasObstacle(boolean hasObstacle) { this.hasObstacle = hasObstacle; }
    public double getObstacleDistance() { return obstacleDistance; }
    public void setObstacleDistance(double obstacleDistance) { this.obstacleDistance = obstacleDistance; }

    @Override
    public String toString() {
        return "环境数据 [时间: " + timestamp +
                ", 土壤湿度: " + soilMoisture +
                ", 土壤pH: " + soilPH +
                ", 温度: " + temperature + "°C" +
                ", 湿度: " + humidity + "%" +
                ", 风速: " + windSpeed + "m/s" +
                ", 作物状态: " + cropStatus +
                ", 障碍物: " + (hasObstacle ? "有(" + obstacleDistance + "m)" : "无") + "]";
    }
}
